#ifndef CAR_H
#define CAR_H
#include<string>
#include<fstream>
#include<iostream>
#include "Subject.h"
#include "Observer.h"
class Car_id 
{
    public:
    string car_id;
    void set(string car_id);
    void get();
    void save();
};
void Car_id::set(string car_id)
{
    this->car_id=car_id;
}
void Car_id::get()
{
    cout<<"小车编号:"<<car_id<<endl;
}
void Car_id::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<car_id<<endl;
    f.close();
}
class Dipan : public Observer
{
    public:
    string id;
    string xinghao;
    string zhouju;
    string lunju;
    string ldjx;
    string zwbj;
    string qudong;
    string xingcheng;
    string luntai;
    string ltxinghao;
    string ltcc;
    string zhuangtai;
    void set(string id,string xinghao,string zhouju,string lunju,string ldjx,string zwbj,string qudong,string xingcheng,string luntai,string ltxinghao,string ltcc)
    {
        this->id=id;
        this->xinghao=xinghao;
        this->zhouju=zhouju;
        this->lunju=lunju;
        this->ldjx=ldjx;
        this->zwbj=zwbj;
        this->qudong=qudong;
        this->xingcheng=xingcheng;
        this->luntai=luntai;
        this->ltxinghao=ltxinghao;
        this->ltcc=ltcc;
    }
    void get();
    void save();
    void update(Subject *subject)
    {
        zhuangtai=subject->getState();
        if(zhuangtai=="前方")
        {
            cout<<"后退"<<endl;
        }
        else if(zhuangtai=="右前方")
        {
            cout<<"向左转"<<endl;
        }
        else if(zhuangtai=="左前方")
        {
            cout<<"向右转"<<endl;
        }
    }
};
void Dipan::get()
{
    cout<<"底盘编号:"<<id<<","<<"型号:"<<xinghao<<","<<"轴距:"<<zhouju<<","<<"轮距:"<<lunju<<endl;
    cout<<"最小离地间隙:"<<ldjx<<","<<"最小转弯半径:"<<zwbj<<","<<"驱动形式:"<<qudong<<","<<"最大行程:"<<xingcheng<<endl;
    cout<<"轮胎:"<<luntai<<","<<"轮胎型号:"<<ltxinghao<<","<<"轮胎尺寸"<<ltcc<<endl;
}
void Dipan::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<id<<" "<<xinghao<<" "<<zhouju<<" "<<lunju<<" "<<ldjx<<" "<<zwbj<<" "<<qudong<<" "<<xingcheng<<" "<<luntai<<" "<<ltxinghao<<" "<<ltcc<<endl;
    f.close();
}
class AXG 
{
    public:
    string xinghao;
    string AI;
    string CUDA;
    string Tensor;
    string xiancun;
    string chucun;
    void set(string xinghao,string AI,string CUDA,string Tensor,string xiancun,string chucun)
    {
        this->xinghao=xinghao;
        this->AI=AI;
        this->CUDA=CUDA;
        this->Tensor=Tensor;
        this->xiancun=xiancun;
        this->chucun=chucun;
    }
    void get();
    void save();
};
void AXG::get()
{
    cout<<"AXG套件型号:"<<xinghao<<","<<"AI"<<AI<<","<<"CUDA核心:"<<"Tensor CORE:"<<Tensor<<","<<"显存:"<<xiancun<<","<<"存储:"<<chucun<<endl;
}
void AXG::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<xinghao<<" "<<AI<<" "<<CUDA<<" "<<Tensor<<" "<<xiancun<<" "<<chucun<<endl;
    f.close();
}
class Camera 
{
    public:
    string xinghao;
    string sxt;
    string RGBfbl;
    string RGB;
    string FOV;
    string sdzl;
    void set(string xinghao,string sxt,string RGBfbl,string RGB,string FOV,string sdzl)
    {
    this->xinghao=xinghao;
    this->sxt=sxt;
    this->RGBfbl=RGBfbl;
    this->RGB=RGB;
    this->FOV=FOV;
    this->sdzl=sdzl;
    }
    void get();
    void save();
};
void Camera::get()
{
    cout<<"双目摄像头型号:"<<xinghao<<","<<"摄像头:"<<sxt<<","<<"RGB帧分辨率:"<<RGBfbl<<","<<"RGB帧率:"<<RGB<<","<<"FOV:"<<FOV<<","<<"深度帧率:"<<sdzl<<endl;
}
void Camera::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<xinghao<<" "<<sxt<<" "<<RGBfbl<<" "<<RGB<<" "<<FOV<<" "<<sdzl<<endl;
    f.close();
}
class Lidar : public Subject
{
    public:
    string xinghao;
    string tds;
    string csfw;
    string gonghao;
    string zhangai;
    void set(string xinghao,string tds,string csfw,string gonghao)
    {
        this->xinghao=xinghao;
        this->tds=tds;
        this->csfw=csfw;
        this->gonghao=gonghao;
    }
    void get();
    void save();
    string getState()
    {
        return zhangai;
    }
    void setState(string s)
    {
        zhangai=s;
    }
};
void Lidar::get()
{
    cout<<"多线激光雷达型号:"<<xinghao<<","<<"通道数:"<<tds<<","<<"测试范围:"<<csfw<<","<<"功耗"<<gonghao<<endl;
}
void Lidar::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<xinghao<<" "<<tds<<" "<<csfw<<" "<<gonghao<<endl;
    f.close();
}
class Gyroscope 
{
    public:
    string xinghao;
    string changjia;
    void set(string xinghao,string changjia)
    {
        this->xinghao=xinghao;
        this->changjia=changjia;
    }
    void get();
    void save();
};
void Gyroscope::get()
{
    cout<<"9轴陀螺仪型号:"<<xinghao<<","<<"厂家:"<<changjia<<endl;
}
void Gyroscope::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<xinghao<<" "<<changjia<<endl;
    f.close();
}
class Screen 
{
    public:
    string xinghao;
    string chicun;
    void set(string xinghao,string chicun)
    {
        this->xinghao=xinghao;
        this->chicun=chicun;
    }
    void get();
    void save();
};
void Screen::get()
{
    cout<<"液晶显示屏型号:"<<xinghao<<","<<"尺寸:"<<chicun<<endl;
}
void Screen::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<xinghao<<" "<<chicun<<endl;
    f.close();
}
class Battery 
{
    public:
    string canshu;
    string gongdian;
    string cdsc;
    void set(string canshu,string gongdian,string cdsc)
    {
        this->canshu=canshu;
        this->gongdian=gongdian;
        this->cdsc=cdsc;
    }
    void get();
    void save();
};
void Battery::get()
{
    cout<<"电池参数:"<<canshu<<","<<"对外供电"<<gongdian<<","<<"充电时长:"<<cdsc<<endl;
}
void Battery::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<canshu<<" "<<gongdian<<" "<<cdsc<<endl;
    f.close();
}
#endif